<template>
    <div>
        <comment :com="com" @nextPage="next"></comment>
    </div>
</template>
<script>
import comment from "../comment.vue"
export default {
    data(){
        return {
            com:[],
            page:1
        }
    },
    components:{
        comment
    },
    methods:{
        getData(){
            this.$http.get("http://comment.com").then(result=>{
                this.com=[]
                if(result.body.state == 0){
                    result.body.data.forEach(item=>{
                        if(item.page<=this.page){
                            this.com.push(item)
                        }
                    })
                }
            })
        },
        next(){
            
            this.page++;
            this.getData()
        }
    },
    created() {
        this.getData()
    },
}
</script>